<template>
  <svg aria-hidden="true" :style="{ fontSize: size }" class="svg-icon-spin">
    <use :xlink:href="symbolId" :fill="props.color" />
  </svg>
</template>

<script lang="ts" setup name="SvgIcon">
import { computed } from 'vue'

const props = defineProps({
  prefix: {
    type: String,
    default: 'icon'
  },
  name: {
    type: String,
    required: true
  },
  color: {
    type: String,
    default: '#333'
  },
  size: {
    type: String,
    default: '16px'
  }
})

const symbolId = computed(() => `#${props.prefix}-${props.name}`)
</script>

<style lang="less" scoped>
.svg-icon-spin {
  width: 1em;
  height: 1em;
  display: inline-block;
  fill: currentColor;
  vertical-align: middle;
}
</style>
